<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>  
<%@ page import="com.wpf.bean.Pagebean" %>
<%@ page import="com.wpf.bean.Querybean" %>
<% String userName = (String)session.getAttribute("username"); %>
<% if(userName==null){ %>
	<jsp:forward page="/wpf_login.jsp"/>
<%}else{ %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生管理系统</title>
<style>
<jsp:include page="./css/allStyle.css" flush="true" />
</style>
<script>
	function confirmDelete() {
		if(confirm("确认删除吗？")){
			testForm.submit();
		}
	}
</script>
</head>
<jsp:useBean id="pageresult" class="com.wpf.bean.Pagebean" scope="session"/>
<jsp:useBean id="lastresult" class="com.wpf.bean.Querybean" scope="session"/>
<body>
	<h1>学生管理系统</h1>
	<h4><font color="grey">查询显示页面</font></h4>
	<p>
	欢迎用户
		<font size='4' color='orange'><strong>
			<%=userName %>
		</strong></font> 
	使用本系统！ 
	</p>
	<%=session.getAttribute("asktip") %>
	<hr>
	<div style="margin-bottom:10px;">
		<form action="wpf_LoginOutServlet" method="post" style="float:left;margin-right:15px;">
			<input class="back bot" type="submit" value="🔴登出">
		</form>
		<form action="wpf_insert.jsp" method="post" style="float:left;margin-right:15px;">
		 	<input class="confirm bot" type="submit" value="➕添加">
		</form>
		<form action="wpf_RefreshData" method="post">
			<% if(lastresult.getFindKey()==null){ %>
				<input class="cantuse bot" type="submit" value="🔄刷新" disabled />
			<%}else{ %>
				<input class="search bot" type="submit" value="🔄刷新" />
		 	<%} %>
		</form>
	</div>
	<form action="wpf_Query" method="post">
		<div style="margin-bottom:10px;">
			查找
			<select name="findkey">
				<option value="id" selected >学号</option>
				<option value="username" >姓名</option>
				<option value="email">邮箱</option>
				<option value="birthday">生日</option>
			</select>
			<select name="findway">
				<option value="0" >完全是</option>
				<option value="1" selected>包含有</option>
				<option value="2" >开头是</option>
				<option value="3" >结尾是</option>
			</select>
			<input type="search" name="findcontent" placeholder="请输入查找内容">
		</div>	
			每页
			<select name="findsort">
				<option value="ASC" selected>升序</option>
				<option value="DESC">降序</option>
			</select>
			显示
			<select name="pagesize">
				<option value="1">全部</option>
				<option value="3" selected>3条</option>
				<option value="5">5条</option>
				<option value="7">7条</option>
			</select>
			数据&nbsp;
			<input class="search bot" type="submit" value="🔍搜索">
			<input class="reset bot" type="reset" value="✖重置">
	 </form>
	 <font size="1" color="grey">查找内容为空时默认搜索全部</font>
<hr>
	<% if(pageresult.getDbAllRow()>0){ %>
	<p style="font-size:18px;">
	共 <strong><font color="red" size="3">
	<%=pageresult.getDbAllRow() %>
	</font></strong> 条
	&nbsp;&nbsp;
	<%if(pageresult.getPageCount()!=1){ %>
	本页 <strong><font color="skyblue" size="3">
	<% if(pageresult.getPageNow()!=pageresult.getPageCount()||pageresult.getDbAllRow()%pageresult.getPageSize()==0){%>
	<%=pageresult.getPageSize() %>	
	<%}else if(pageresult.getDbAllRow()%pageresult.getPageSize()!=0){%>
	<%=pageresult.getDbAllRow()%pageresult.getPageSize() %>
	<%} %>
	</font></strong> 条
	<%} %>
	<%} %>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<strong><%=(session.getAttribute("operationtip")==null ? "" : session.getAttribute("operationtip") ) %></strong>
	</p>
 <%=pageresult.getQueryResult() %>
 <br>
<% if(pageresult.getPageCount()>1){ %>
<form action="wpf_ShowPage" method="post">
	<% if(pageresult.getPageNow()==1){ %>
		<input class="cantuse bot" type="submit" name="action" value="首页" disabled/>
		<input class="cantuse bot" type="submit" name="action" value="上一页" disabled/>
	<%}else{ %>
		<input class="search bot" type="submit" name="action" value="首页" />
		<input class="search bot" type="submit" name="action" value="上一页" />
	<%}%>
	&nbsp;
	<strong>
		<font color="green">
			<%=pageresult.getPageNow() %>
		</font>
		/
		<font color="brown">
			<%=pageresult.getPageCount() %>
		</font>
	</strong>
	&nbsp;
	<% if(pageresult.getPageNow()==pageresult.getPageCount()){ %>
		<input class="cantuse bot" type="submit" name="action" value="下一页" disabled />
		<input class="cantuse bot" type="submit" name="action" value="页尾" disabled />
	<%}else{ %>
		<input class="search bot" type="submit" name="action" value="下一页" />
		<input class="search bot" type="submit" name="action" value="页尾" />
	<%}%>
	<input class="confirm bot" type="submit" name="action" value="跳转" />
	<select name="jumppagenum">
		<% for(int i=1;i<=pageresult.getPageCount();i++){
			if(i==pageresult.getPageNow()){
		%>
				<option value="<%=i %>" selected><%=i %></option>
			<%}else{ %>
				<option value="<%=i %>"><%=i %></option>
			<%} %>
		<%} %>
	 </select>
</form>
<%} %>
</body>
</html>
<%} %>
